import { ServiceApproveStatusEnum } from '@/core/enums/status'
import { HasMovedEnum } from '@/core/enums/type'
import { ServiceApproveStatusKeyMap } from '@/core/mapper/status'
import type { Promotion } from '@/core/interfaces/promotion'

export function handleMovedPlan(status?: ServiceApproveStatusEnum, hasMoved?: HasMovedEnum) {
  return ServiceApproveStatusEnum.PausePromotion === status && hasMoved === HasMovedEnum.move
}

export function transformMovedStatus(record: Partial<Promotion>) {
  const { serviceApproveStatus, hasMoved } = record

  if (handleMovedPlan(serviceApproveStatus, hasMoved)) {
    return ServiceApproveStatusKeyMap[ServiceApproveStatusEnum.Enable]
  } else {
    return ServiceApproveStatusKeyMap[serviceApproveStatus!]
  }
}
